'''
''' Override this method to filter the ${Second Filter Control}DropDownList
''' based on the value selected for the ${First Filter Control}DropDownList
'''
Protected Sub Populate${Second Filter Control}DropDown(ByVal maxItems As Integer)
' Set up the WHERE clause.
' Create the WHERE clause to filter the second filter based on
' the selected value of first filter.
Dim wc As WhereClause = New WhereClause
Dim selectedValue As String = ${First Filter Control}.SelectedValue
Dim selectedText As String = ${First Filter Control}.SelectedItem.Text
wc.iAND(${${Table}ClassName}.${First Filter Field}, BaseFilter.ComparisonOperator.EqualsTo, selectedValue)
' Clear the contents of second filter.
Me.${Second Filter Control}.Items.Clear()
' Add "Please Select" string to the second filter.
Me.${Second Filter Control}.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"), "--PLEASE_SELECT--"))
If (BaseClasses.Utils.StringUtils.InvariantUCase(selectedText).Equals(BaseClasses.Utils.StringUtils.InvariantUCase(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"))))
' if "Please Select" string is selected for first filter,
' then do not continue populating the second filter.
Return
End If
' Get the records using the created where clause.
Dim itemValue As ${${Table}RecordClassName}
For Each itemValue In ${${Table}ClassName}.GetRecords(wc, Nothing, 0, maxItems)
If (itemValue.${Second Filter Field}Specified)
' In each record, obtain the value of second dropdown field if value exists,
' create an item for it and add it to the list.
Dim cvalue As String = itemValue.${Second Filter Field}.ToString()
Dim fvalue As String = itemValue.Format(${${Table}ClassName}.${Second Filter Field})
Dim item As ListItem = New ListItem(fvalue, cvalue)
If (Not Me.${Second Filter Control}.Items.Contains(item))
Me.${Second Filter Control}.Items.Add(item)
End If
End If
Next
' Select "Please Select" string in the second filter.
Me.${Second Filter Control}.SelectedIndex = 0
End Sub
|